﻿namespace System.Net.DnsToolkit.SocketAsync {
    public class UdpClientEventArgs : EventArgs {

        private readonly object _ticket;
        public object Ticket {
            get {
                return _ticket;
            }
        }

        private readonly Exception _exception;
        public Exception Exception {
            get {
                return _exception;
            }
        }

        private readonly bool _hasException;
        public bool HasException {
            get {
                return _hasException;
            }
        }

        public bool Treated { get; set; }

        private readonly byte[] _buffer;
        public byte[] Buffer {
            get {
                return _buffer;
            }
        }

        private readonly int _offset;
        public int Offset {
            get {
                return _offset;
            }
        }

        private readonly int _length;
        public int Length {
            get {
                return _length;
            }
        }

        internal UdpClientEventArgs(object ticket) {

            _hasException = false;
            Treated = false;
            _exception = null;
            _buffer = null;
            _offset = 0;
            _length = 0;
            _ticket = ticket;
        }

        internal UdpClientEventArgs(object ticket, byte[] buffer, int offset, int length) {

            _hasException = false;
            Treated = false;
            _exception = null;
            _buffer = buffer;
            _offset = offset;
            _length = length;
            _ticket = ticket;

        }

        internal UdpClientEventArgs(object ticket, Exception e) {

            _hasException = true;
            Treated = false;
            _exception = e;
            _ticket = ticket;

        }

    }
}
